package net.wing.demo.controller;

import com.alibaba.fastjson.JSONObject;
import net.wing.demo.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * @Author beifengtz
 * @Date Created in 8:58 2018/8/10
 * @Description:
 */
@Controller
public class MessageController {

    @Autowired
    private MessageService messageService;

    /**
     * @Author beifengtz
     * @Date Created in 2018/8/10 9:06
     * @Description: 获取所有留言信息的控制层
     * @param none
     * @return json
     */
    @GetMapping("pub/getAllMessage")
    @ResponseBody
    public JSONObject getAllMessage(){
        return messageService.getAllMessages();
    }
    @PostMapping("nopub/setMessage")
    @ResponseBody
    public JSONObject setMessage(@RequestParam("content") String content,
                                 @RequestParam("date") int date){
        return messageService.setMessage(content,date);
    }
}
